package iss.anxios.dao;

import iss.anxios.dto.Respondent;
import iss.anxios.dto.RespondentAttributeAssociation;

import java.util.List;

import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

import org.springframework.stereotype.Repository;
import org.springframework.transaction.annotation.Transactional;

@Repository("respondentdao")
public class RespondentDaoImpl implements RespondentDao {

	@PersistenceContext
	EntityManager em;
	
	
	@Transactional
	@SuppressWarnings("unchecked")
	public List<Respondent> ListRespondent() {
		return em.createQuery("select r from Respondent r").getResultList();
	}
	
	@Transactional
	@SuppressWarnings("unchecked")
	public List<RespondentAttributeAssociation> ListRespondentAttributeAssociation() {
		System.out.println("I am in the respondent attribute.......");
		List<RespondentAttributeAssociation> list = em.createQuery("Select ras from RespondentAttributeAssociation ras").getResultList();
	    if(null == list){
	    	System.out.println("list is null");
	    }
	    else{
		int s = list.size();
	
	    	System.out.println(s + "sdfghjkhgfdsdfghj");
	    
	    	//System.out.println(list.get(0).getAttributeId());
	    }
	    return list;
	    
	    
	}

}
